<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: scripts/vueMethods.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: scripts/vueMethods.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * vue全局函数
 * @module
 */

export default function(Vue) {
  /**
   * 获取当前错误信息
   * @method matchError
   * @memberof Vue
   * @param  {String} name   表单元素的name
   * @param  {Object} errors 错误信息集合
   * @return {String}        第一个匹配到的当前错误信息
   */
  Vue.prototype.matchError=function(state,name,errors){ 
    var input=state[name];
    if (input&amp;&amp;input.pristine&amp;&amp;input.$error.required) {return ''}
    if (input&amp;&amp;input.$invalid) {
      for(var i in errors){
        if (input.$error[i]) {
          return errors[i]
        }
      }
    }
    return ''
  }

  /**
   * 删除对象内值空或空数组或空对象的属性
   * @method trimObject
   * @memberof Vue
   * @param  {Object} obj 目标对象
   * @param  {Boolean} replace 是否替换原对象,缺省值为false
   * @return {Object}     返回修剪后的对象
   */
  Vue.prototype.trimObject=function(obj,replace){
    var newObj={}
    for(var j in obj){
      if (typeof obj[j]!=='undefined'&amp;&amp;obj[j]!==''&amp;&amp;obj[j]!==null&amp;&amp;!(obj[j] instanceof Array===true&amp;&amp;obj[j].length===0)&amp;&amp;!(typeof obj[j]==='object'&amp;&amp;JSON.stringify(obj[j])==='{}')) {
        Vue.set(newObj,j,obj[j])
      }
    }
    if (replace!==true) {
      return newObj
    }else{
      obj=newObj
      return obj
    }
  }
}
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-components_appCalendar.html">components/appCalendar</a></li><li><a href="module-components_appLoading.html">components/appLoading</a></li><li><a href="module-components_appUserBox.html">components/appUserBox</a></li><li><a href="module-components_editImage.html">components/editImage</a></li><li><a href="module-components_fileList.html">components/fileList</a></li><li><a href="module-components_menuNava_menuNava.html">components/menuNava/menuNava</a></li><li><a href="module-components_menuNava_menuNavaItem.html">components/menuNava/menuNavaItem</a></li><li><a href="module-components_myInputPage.html">components/myInputPage</a></li><li><a href="module-components_mySelectPage.html">components/mySelectPage</a></li><li><a href="module-components_myWebuploader.html">components/myWebuploader</a></li><li><a href="module-components_textImgBox.html">components/textImgBox</a></li><li><a href="module-components_timeline_timeline.html">components/timeline/timeline</a></li><li><a href="module-components_timeline_timelineItem.html">components/timeline/timelineItem</a></li><li><a href="module-components_vImg.html">components/vImg</a></li><li><a href="module-scripts_common.html">scripts/common</a></li><li><a href="module-scripts_configValid.html">scripts/configValid</a></li><li><a href="module-scripts_LunarCalendar.html">scripts/LunarCalendar</a></li><li><a href="module-scripts_vueMethods.html">scripts/vueMethods</a></li><li><a href="module-services.html">services</a></li><li><a href="module-services_AnniversaryService.html">services/AnniversaryService</a></li><li><a href="module-services_ArchiveService.html">services/ArchiveService</a></li><li><a href="module-services_BigEventService.html">services/BigEventService</a></li><li><a href="module-services_FamilyService.html">services/FamilyService</a></li><li><a href="module-services_UserService.html">services/UserService</a></li><li><a href="module-vuex-history.html">vuex-history</a></li><li><a href="module-vuex-loading.html">vuex-loading</a></li><li><a href="module-vuex-toast.html">vuex-toast</a></li></ul><h3>Namespaces</h3><ul><li><a href="Vue.html">Vue</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jun 30 2017 09:20:36 GMT+0800 (中国标准时间)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
